<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>招聘需求</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
  <link rel="stylesheet" href="../layuimini/css/public.css" media="all">
</head>
<body>
<input type="hidden" name="empid" th:value="${session.loginUser.getEmpId()}">
<table id="table-user" class="layui-table" lay-filter="table-user"></table>
<script type="text/html" id="currentTableBar">
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="jeu">修改</a>
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="insert">申请面试</a>
</script>
<script type="text/html" id="toolbar">
  <div class="layui-btn-container">
    <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-filter="data-search-btn" lay-event="add"> 添加 </button>
  </div>
</script>
<script src="../layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script th:inline="none">
  layui.use(['form', 'table'], function () {
    var $ = layui.jquery;
    var form = layui.form;
    var table = layui.table;
    let id=$(":input[name='empid']").val();
    table.render({
      elem: '#table-user',
      url: '/demand/list?',
      method:'post',
      page: true,
      limits: [1,5,10,15],
      limit: 10,
      cols: [[
        {type: "checkbox", width: 50},
        {field: 'dnumber', title: '需求人数'},
        {field: 'departmentname', title: '部门类型',templet:function (d){return d.departmentname.name}},
        {field: 'rolename', title: '角色类型'},
        {field: 'roleadd',title: '新增角色'},
        {field: 'degree', title: '学历要求'},
        {field: 'agelimit', title: '工作年限', sort: true},
        {field: 'recruitment',title: '招聘需求'},
        {field: 'recruitname', title: '招聘负责人'},
        {field: 'statename', title: '状态名称',templet:function (d){return d.statename.stateName}},
        {field: 'releasetime',title: '创建时间', sort: true},
        {title: '操作', toolbar: '#currentTableBar', align: "center",width:150}
      ]],
      toolbar:"#toolbar",
    });

    /*添加计划*/
    table.on('toolbar(table-user)', function (obj) {
      if (obj.event === 'add') {  // 监听添加操作
        var index = layer.open({
          title: '添加招聘需求',
          type: 2,
          shade: 0.2,
          maxmin:true,
          shadeClose: true,
          area: ['50%', '100%'],
          content: '/demand/insert',
        });
        $(window).on("resize", function () {
          layer.full(index);
        });
      }
    });

    table.on('tool(table-user)', function (obj) {
      if (obj.event==='jeu'){
        let id=obj.data.id;
          var index = layer.open({
            title: '修改招聘需求',
            type: 2,
            shade: 0.2,
            maxmin:true,
            shadeClose: true,
            area: ['100%', '100%'],
            content: '/demand/updemand?id='+id,
          });
          $(window).on("resize", function () {
            layer.full(index);
          });
        }else if (obj.event==='insert'){
        let iid=obj.data.statename.id;
        if (iid==10){
          let id=obj.data.id;
          var index = layer.open({
            title: '填写面试需求',
            type: 2,
            shade: 0.2,
            maxmin:true,
            shadeClose: true,
            area: ['100%', '100%'],
            content: '/demand/stinsert?id='+id,
          });
          $(window).on("resize", function () {
            layer.full(index);
          });
        }else{
          alert("请选择其他岗位申请");
        }

      }
    });

    form.on('submit(data-search-btn)',function(data){
      var result=JSON.stringify(data.field);
      console.log(result);
      //执行搜索重载
      table.reload('table-user',{
        page:{
          curr:1
        },
      },'data');
      //阻止表单提交
      return false;
    })
  });
</script>
</body>
</html>